package zunyi04;

/**
 * 模拟账户
 */
public class Account {
    private int id;//账号
    protected double balance;//余额
    private double annualInterRate;//年利率

    public Account() {
    }

    public Account(int id, double balance, double annualInterRate) {
        this.id = id;
        this.balance = balance;
        this.annualInterRate = annualInterRate;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    public double getAnnualInterRate() {
        return annualInterRate;
    }

    public void setAnnualInterRate(double annualInterRate) {
        this.annualInterRate = annualInterRate;
    }

    //取款
    public void withdraw(double quKuan){
        if(this.balance < quKuan){
            System.out.println("余额不足，取钱失败");
        }
        else{
            this.setBalance(this.getBalance() - quKuan);
            System.out.println("成功取出：" + quKuan);
        }
    }
    //存钱
    public void deposit(double cunKuan){
        this.setBalance(this.getBalance() + cunKuan);
        System.out.println("成功存入：" + cunKuan);
    }
    //月利率
    public void MinthlyInterestRate()
    {
        if(this.annualInterRate==0)
        {
            System.out.println("还没设置利息呢");
        }else {
            System.out.println("月利率"+annualInterRate/12);
        }
    }
}

